<template>
	<view class=" padding-lr">
		<!-- <view class="flex  padding-tb" @click="goNav('/pages/public/pwd')">
			<view class="flex-sub text-df" style="line-height: 50upx;">修改密码</view>
			<image src="../../../static/image/go.png" style="line-height: 50upx;width: 15rpx;height: 30rpx;">
			</image>
		</view> -->
		<!-- #ifdef MP-WEIXIN -->
		<view class="flex  padding-tb" @click="bindMsg">
			<view class="flex-sub text-df" style="line-height: 50upx;">订阅消息</view>
			<view class="jia">
				<u-icon name="plus" color="#FFFFFF"></u-icon>
			</view>
		</view>
		<!-- #endif -->
		<view class="flex  padding-tb" @click="goNav('/pages/riderMy/trainingList')">
			<view class="flex-sub text-df" style="line-height: 50upx;">帮助中心</view>
			<image src="../../../static/image/go.png" style="line-height: 50upx;width: 15rpx;height: 30rpx;">
			</image>
		</view>
		<view class="flex  padding-tb" @click="goNav('/pages/riderMy/set/xieyi')">
			<view class="flex-sub text-df" style="line-height: 50upx;">用户协议</view>
			<image src="../../../static/image/go.png" style="line-height: 50upx;width: 15rpx;height: 30rpx;">
			</image>
		</view>
		<view class="flex  padding-tb" @click="goNav('/pages/riderMy/set/mimi')">
			<view class="flex-sub text-df" style="line-height: 50upx;">隐私政策</view>
			<image src="../../../static/image/go.png" style="line-height: 50upx;width: 15rpx;height: 30rpx;">
			</image>
		</view>
		<view class="flex  padding-tb" @click="goNav('/pages/riderMy/set/about')">
			<view class="flex-sub text-df" style="line-height: 50upx;">关于我们</view>
			<image src="../../../static/image/go.png" style="line-height: 50upx;width: 15rpx;height: 30rpx;">
			</image>
		</view>
		<view class="btn" @click="TuiLogin">退出登录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId: "",
				arr: []
			}
		},
		onLoad() {
			this.userId = uni.getStorageSync('userId')
			let that = this;
			//骑手端接单成功通知
			that.$Request.getT('/app/common/type/310').then(res => {
				if (res.code === 0) {
					// this.jiedan = res.data.value
					that.arr.push(res.data.value)
				}
			});
			//骑手端订单完成通知
			that.$Request.getT('/app/common/type/311').then(res => {
				if (res.code === 0) {
					// this.jiedanSuccess = res.data.value
					that.arr.push(res.data.value)
				}
			});
			//用户端骑手转单订单通知 338
			that.$Request.getT('/app/common/type/338').then(res => {
				if (res.code === 0) {
					that.arr.push(res.data.value)
				}
			});
		},
		methods: {
			bindMsg() {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
								uni.showToast({
									title: '订阅成功',
									icon: 'none'
								})
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
			},
			goNav(e) {
				uni.navigateTo({
					url: e
				})
			},
			//退出登录
			TuiLogin() {
				let that = this

				if (that.userId) {
					uni.showModal({
						title: '提示',
						content: '确认退出登录吗?',
						success: function(res) {
							if (res.confirm) {
								uni.removeStorageSync('userId')
								uni.removeStorageSync('token')
								uni.removeStorageSync('avatar')
								uni.removeStorageSync('nickName')
								uni.removeStorageSync('phone')
								uni.removeStorageSync('invitationCode')
								uni.removeStorageSync('inviterCode')
								uni.removeStorageSync('platform')
								uni.removeStorageSync('sex')
								uni.removeStorageSync('zhiFuBao')
								uni.removeStorageSync('zhiFuBaoName')
								uni.removeStorageSync('checkCertification')

								// uni.navigateBack()
								uni.redirectTo({
									url: '/pages/index/index'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/my/loginphone'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}


			},
		}

	}
</script>

<style>
	page {
		background: #FFFFFF;
	}

	.jia {
		background: #FF6A04;
		border-radius: 50%;
		width: 55rpx;
		height: 55rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.btn {
		width: 100%;
		height: 80upx;
		background: #FF6A04;
		color: #FFFFFF;
		border-radius: 6upx;
		text-align: center;
		line-height: 80upx;
		margin-top: 40upx;
		font-size: 34upx;
		/* color: #fff; */
	}
</style>